use crate::REQWEST_CLIENT;
use anyhow::Result;
use serde::{ Deserialize, Serialize };
use serde_json::Value;
/// 杜邦分析 Mapping to [RPT_F10_FINANCE_DUPONT.json](file:///Users/CC/gitee/conanchen/fuquants-workspace/crates/fudacli/eastmoney/sample/RPT_F10_FINANCE_DUPONT.json)
#[derive(Debug, Serialize, Deserialize)]
pub struct RptF10FinanceDupont {
    pub version: Value,
    pub result: RptF10FinanceDupontResult,
    pub success: Value,
    pub message: Value,
    pub code: Value,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RptF10FinanceDupontResult {
    pub pages: Value,
    pub data: Vec<RptF10FinanceDupontResultData>,
    pub count: Option<Value>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RptF10FinanceDupontResultData {
    #[serde(rename = "SECUCODE")]
    pub secucode: Option<Value>, // 证券代码
    #[serde(rename = "SECURITY_CODE")]
    pub security_code: Option<Value>, // 证券代码
    #[serde(rename = "SECURITY_NAME_ABBR")]
    pub security_name_abbr: Option<Value>, // 证券简称
    #[serde(rename = "ORG_CODE")]
    pub org_code: Option<Value>, // 机构代码
    #[serde(rename = "ORG_TYPE")]
    pub org_type: Option<Value>, // 机构类型
    #[serde(rename = "REPORT_DATE")]
    pub report_date: Option<Value>, // 报告日期
    #[serde(rename = "REPORT_TYPE")]
    pub report_type: Option<Value>, // 报告类型
    #[serde(rename = "REPORT_DATE_NAME")]
    pub report_date_name: Option<Value>, // 报告日期名称
    #[serde(rename = "SECURITY_TYPE_CODE")]
    pub security_type_code: Option<Value>, // 证券类型代码
    #[serde(rename = "NOTICE_DATE")]
    pub notice_date: Option<Value>, // 公告日期
    #[serde(rename = "UPDATE_DATE")]
    pub update_date: Option<Value>, // 更新日期
    #[serde(rename = "CURRENCY")]
    pub currency: Option<Value>, // 货币
    #[serde(rename = "NETPROFIT")]
    pub netprofit: Option<Value>, // 净利润
    #[serde(rename = "TOTAL_OPERATE_INCOME")]
    pub total_operate_income: Option<Value>, // 营业总收入
    #[serde(rename = "TOTAL_ASSETS")]
    pub total_assets: Option<Value>, // 总资产
    #[serde(rename = "TOTAL_LIABILITIES")]
    pub total_liabilities: Option<Value>, // 总负债
    #[serde(rename = "TOTAL_CURRENT_ASSETS")]
    pub total_current_assets: Option<Value>, // 总流动资产
    #[serde(rename = "TOTAL_NONCURRENT_ASSETS")]
    pub total_noncurrent_assets: Option<Value>, // 总非流动资产
    #[serde(rename = "PARENT_NETPROFIT")]
    pub parent_netprofit: Option<Value>, // 母公司净利润
    #[serde(rename = "SALE_NPR")]
    pub sale_npr: Option<Value>, // 销售净利率
    #[serde(rename = "TOTAL_ASSETS_TR")]
    pub total_assets_tr: Option<Value>, // 总资产周转率
    #[serde(rename = "JROA")]
    pub jroa: Option<Value>, // 净资产收益率
    #[serde(rename = "PARENT_NETPROFIT_RATIO")]
    pub parent_netprofit_ratio: Option<Value>, // 母公司净利润占比
    #[serde(rename = "EQUITY_MULTIPLIER")]
    pub equity_multiplier: Option<Value>, // 权益乘数
    #[serde(rename = "ROE")]
    pub roe: Option<Value>, // 净资产收益率
    #[serde(rename = "DEBT_ASSET_RATIO")]
    pub debt_asset_ratio: Option<Value>, // 资产负债率
    #[serde(rename = "TOTAL_INCOME")]
    pub total_income: Option<Value>, // 总收入
    #[serde(rename = "TOTAL_COST")]
    pub total_cost: Option<Value>, // 总成本
    #[serde(rename = "TOTAL_EXPENSE")]
    pub total_expense: Option<Value>, // 总费用
    #[serde(rename = "MONETARYFUNDS")]
    pub monetaryfunds: Option<Value>, // 货币资金
    #[serde(rename = "TRADE_FINASSET")]
    pub trade_finasset: Option<Value>, // 交易性金融资产
    #[serde(rename = "NOTE_RECE")]
    pub note_rece: Option<Value>, // 应收票据
    #[serde(rename = "ACCOUNTS_RECE")]
    pub accounts_rece: Option<Value>, // 应收账款
    #[serde(rename = "FINANCE_RECE")]
    pub finance_rece: Option<Value>, // 应收款项
    #[serde(rename = "OTHER_RECE")]
    pub other_rece: Option<Value>, // 其他应收款
    #[serde(rename = "INVENTORY")]
    pub inventory: Option<Value>, // 存货
    #[serde(rename = "CREDITOR_INVEST")]
    pub creditor_invest: Option<Value>, // 应付款项
    #[serde(rename = "LONG_EQUITY_INVEST")]
    pub long_equity_invest: Option<Value>, // 长期股权投资
    #[serde(rename = "INVEST_REALESTATE")]
    pub invest_realestate: Option<Value>, // 投资房地产
    #[serde(rename = "FIXED_ASSET")]
    pub fixed_asset: Option<Value>, // 固定资产
    #[serde(rename = "CIP")]
    pub cip: Option<Value>, // 在建工程
    #[serde(rename = "USERIGHT_ASSET")]
    pub useright_asset: Option<Value>, // 使用权资产
    #[serde(rename = "INTANGIBLE_ASSET")]
    pub intangible_asset: Option<Value>, // 无形资产
    #[serde(rename = "DEVELOP_EXPENSE")]
    pub develop_expense: Option<Value>, // 研发支出
    #[serde(rename = "GOODWILL")]
    pub goodwill: Option<Value>, // 商誉
    #[serde(rename = "LONG_PREPAID_EXPENSE")]
    pub long_prepaid_expense: Option<Value>, // 长期待摊费用
    #[serde(rename = "DEFER_TAX_ASSET")]
    pub defer_tax_asset: Option<Value>, // 递延所得税资产
    #[serde(rename = "INVEST_INCOME")]
    pub invest_income: Option<Value>, // 投资收益
    #[serde(rename = "EXCHANGE_INCOME")]
    pub exchange_income: Option<Value>, // 汇兑收益
    #[serde(rename = "FAIRVALUE_CHANGE_INCOME")]
    pub fairvalue_change_income: Option<Value>, // 公允价值变动收益
    #[serde(rename = "ASSET_DISPOSAL_INCOME")]
    pub asset_disposal_income: Option<Value>, // 资产处置收益
    #[serde(rename = "OPERATE_COST")]
    pub operate_cost: Option<Value>, // 营业成本
    #[serde(rename = "SURRENDER_VALUE")]
    pub surrender_value: Option<Value>, // 退保金
    #[serde(rename = "NET_COMPENSATE_EXPENSE")]
    pub net_compensate_expense: Option<Value>, // 净赔付支出
    #[serde(rename = "NET_CONTRACT_RESERVE")]
    pub net_contract_reserve: Option<Value>, // 净合同准备金
    #[serde(rename = "POLICY_BONUS_EXPENSE")]
    pub policy_bonus_expense: Option<Value>, // 保单红利支出
    #[serde(rename = "OPERATE_TAX_ADD")]
    pub operate_tax_add: Option<Value>, // 营业税金及附加
    #[serde(rename = "INCOME_TAX")]
    pub income_tax: Option<Value>, // 所得税费用
    #[serde(rename = "ASSET_IMPAIRMENT_INCOME")]
    pub asset_impairment_income: Option<Value>, // 资产减值收益
    #[serde(rename = "CREDIT_IMPAIRMENT_INCOME")]
    pub credit_impairment_income: Option<Value>, // 信用减值损失转回收益
    #[serde(rename = "NONBUSINESS_EXPENSE")]
    pub nonbusiness_expense: Option<Value>, // 营业外支出
    #[serde(rename = "FINANCE_EXPENSE")]
    pub finance_expense: Option<Value>, // 财务费用
    #[serde(rename = "SALE_EXPENSE")]
    pub sale_expense: Option<Value>, // 销售费用
    #[serde(rename = "MANAGE_EXPENSE")]
    pub manage_expense: Option<Value>, // 管理费用
    #[serde(rename = "RESEARCH_EXPENSE")]
    pub research_expense: Option<Value>, // 研究费用
    #[serde(rename = "INTEREST_NI")]
    pub interest_ni: Option<Value>, // 利息净收入
    #[serde(rename = "FEE_COMMISSION_NI")]
    pub fee_commission_ni: Option<Value>, // 手续费及佣金净收入
    #[serde(rename = "EARNED_PREMIUM")]
    pub earned_premium: Option<Value>, // 已赚保费
    #[serde(rename = "BUSINESS_MANAGE_EXPENSE")]
    pub business_manage_expense: Option<Value>, // 业务及管理费用
    #[serde(rename = "OTHER_CREDITOR_INVEST")]
    pub other_creditor_invest: Option<Value>, // 其他应收款投资
    #[serde(rename = "OTHER_EQUITY_INVEST")]
    pub other_equity_invest: Option<Value>, // 其他权益工具投资
    #[serde(rename = "LONG_RECE")]
    pub long_rece: Option<Value>, // 长期应收款
    #[serde(rename = "AVAILABLE_SALE_FINASSET")]
    pub available_sale_finasset: Option<Value>, // 可供出售金融资产
    #[serde(rename = "HOLD_MATURITY_INVEST")]
    pub hold_maturity_invest: Option<Value>, // 持有至到期投资
    #[serde(rename = "FEE_COMMISSION_EXPENSE")]
    pub fee_commission_expense: Option<Value>, // 手续费及佣金支出
}

impl RptF10FinanceDupont {
    /// 杜邦分析 RPT_F10_FINANCE_DUPONT 按报告期
    /// Referer: https://emweb.securities.eastmoney.com/pc_hsf10/pages/index.html?type=web&code=SZ000001&color=b#/cwfx/dbfx
    ///
    /// data: https://datacenter.eastmoney.com/securities/api/data/v1/get?reportName=RPT_F10_FINANCE_DUPONT&columns=SECUCODE%2CSECURITY_CODE%2CSECURITY_NAME_ABBR%2CORG_CODE%2CORG_TYPE%2CREPORT_DATE%2CREPORT_TYPE%2CREPORT_DATE_NAME%2CSECURITY_TYPE_CODE%2CNOTICE_DATE%2CUPDATE_DATE%2CCURRENCY%2CNETPROFIT%2CTOTAL_OPERATE_INCOME%2CTOTAL_ASSETS%2CTOTAL_LIABILITIES%2CTOTAL_CURRENT_ASSETS%2CTOTAL_NONCURRENT_ASSETS%2CPARENT_NETPROFIT%2CSALE_NPR%2CTOTAL_ASSETS_TR%2CJROA%2CPARENT_NETPROFIT_RATIO%2CEQUITY_MULTIPLIER%2CROE%2CDEBT_ASSET_RATIO%2CTOTAL_INCOME%2CTOTAL_COST%2CTOTAL_EXPENSE%2CMONETARYFUNDS%2CTRADE_FINASSET%2CNOTE_RECE%2CACCOUNTS_RECE%2CFINANCE_RECE%2COTHER_RECE%2CINVENTORY%2CCREDITOR_INVEST%2CLONG_EQUITY_INVEST%2CINVEST_REALESTATE%2CFIXED_ASSET%2CCIP%2CUSERIGHT_ASSET%2CINTANGIBLE_ASSET%2CDEVELOP_EXPENSE%2CGOODWILL%2CLONG_PREPAID_EXPENSE%2CDEFER_TAX_ASSET%2CINVEST_INCOME%2CEXCHANGE_INCOME%2CFAIRVALUE_CHANGE_INCOME%2CASSET_DISPOSAL_INCOME%2COPERATE_COST%2CSURRENDER_VALUE%2CNET_COMPENSATE_EXPENSE%2CNET_CONTRACT_RESERVE%2CPOLICY_BONUS_EXPENSE%2COPERATE_TAX_ADD%2CINCOME_TAX%2CASSET_IMPAIRMENT_INCOME%2CCREDIT_IMPAIRMENT_INCOME%2CNONBUSINESS_EXPENSE%2CFINANCE_EXPENSE%2CSALE_EXPENSE%2CMANAGE_EXPENSE%2CRESEARCH_EXPENSE%2CINTEREST_NI%2CFEE_COMMISSION_NI%2CEARNED_PREMIUM%2CBUSINESS_MANAGE_EXPENSE%2COTHER_CREDITOR_INVEST%2COTHER_EQUITY_INVEST%2CLONG_RECE%2CAVAILABLE_SALE_FINASSET%2CHOLD_MATURITY_INVEST%2CFEE_COMMISSION_EXPENSE&quoteColumns=&filter=(SECUCODE%3D%22000001.SZ%22)&pageNumber=1&pageSize=9&sortTypes=-1&sortColumns=REPORT_DATE&source=HSF10&client=PC&v=09586109542970322
    pub async fn rpt_f10_finance_dupont(_code: &str) -> Result<RptF10FinanceDupont> {
        // Query String Parameters:
        //
        // reportName: RPT_F10_FINANCE_DUPONT
        // columns: SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,ORG_CODE,ORG_TYPE,REPORT_DATE,REPORT_TYPE,REPORT_DATE_NAME,SECURITY_TYPE_CODE,NOTICE_DATE,UPDATE_DATE,CURRENCY,NETPROFIT,TOTAL_OPERATE_INCOME,TOTAL_ASSETS,TOTAL_LIABILITIES,TOTAL_CURRENT_ASSETS,TOTAL_NONCURRENT_ASSETS,PARENT_NETPROFIT,SALE_NPR,TOTAL_ASSETS_TR,JROA,PARENT_NETPROFIT_RATIO,EQUITY_MULTIPLIER,ROE,DEBT_ASSET_RATIO,TOTAL_INCOME,TOTAL_COST,TOTAL_EXPENSE,MONETARYFUNDS,TRADE_FINASSET,NOTE_RECE,ACCOUNTS_RECE,FINANCE_RECE,OTHER_RECE,INVENTORY,CREDITOR_INVEST,LONG_EQUITY_INVEST,INVEST_REALESTATE,FIXED_ASSET,CIP,USERIGHT_ASSET,INTANGIBLE_ASSET,DEVELOP_EXPENSE,GOODWILL,LONG_PREPAID_EXPENSE,DEFER_TAX_ASSET,INVEST_INCOME,EXCHANGE_INCOME,FAIRVALUE_CHANGE_INCOME,ASSET_DISPOSAL_INCOME,OPERATE_COST,SURRENDER_VALUE,NET_COMPENSATE_EXPENSE,NET_CONTRACT_RESERVE,POLICY_BONUS_EXPENSE,OPERATE_TAX_ADD,INCOME_TAX,ASSET_IMPAIRMENT_INCOME,CREDIT_IMPAIRMENT_INCOME,NONBUSINESS_EXPENSE,FINANCE_EXPENSE,SALE_EXPENSE,MANAGE_EXPENSE,RESEARCH_EXPENSE,INTEREST_NI,FEE_COMMISSION_NI,EARNED_PREMIUM,BUSINESS_MANAGE_EXPENSE,OTHER_CREDITOR_INVEST,OTHER_EQUITY_INVEST,LONG_RECE,AVAILABLE_SALE_FINASSET,HOLD_MATURITY_INVEST,FEE_COMMISSION_EXPENSE
        // quoteColumns:
        // filter: (SECUCODE="000001.SZ")
        // pageNumber: 1
        // pageSize: 9
        // sortTypes: -1
        // sortColumns: REPORT_DATE
        // source: HSF10
        // client: PC
        // v: 09199164773143118

        let request_url = format!(
            "https://datacenter.eastmoney.com/securities/api/data/v1/get?reportName=RPT_F10_FINANCE_DUPONT&columns=SECUCODE%2CSECURITY_CODE%2CSECURITY_NAME_ABBR%2CORG_CODE%2CORG_TYPE%2CREPORT_DATE%2CREPORT_TYPE%2CREPORT_DATE_NAME%2CSECURITY_TYPE_CODE%2CNOTICE_DATE%2CUPDATE_DATE%2CCURRENCY%2CNETPROFIT%2CTOTAL_OPERATE_INCOME%2CTOTAL_ASSETS%2CTOTAL_LIABILITIES%2CTOTAL_CURRENT_ASSETS%2CTOTAL_NONCURRENT_ASSETS%2CPARENT_NETPROFIT%2CSALE_NPR%2CTOTAL_ASSETS_TR%2CJROA%2CPARENT_NETPROFIT_RATIO%2CEQUITY_MULTIPLIER%2CROE%2CDEBT_ASSET_RATIO%2CTOTAL_INCOME%2CTOTAL_COST%2CTOTAL_EXPENSE%2CMONETARYFUNDS%2CTRADE_FINASSET%2CNOTE_RECE%2CACCOUNTS_RECE%2CFINANCE_RECE%2COTHER_RECE%2CINVENTORY%2CCREDITOR_INVEST%2CLONG_EQUITY_INVEST%2CINVEST_REALESTATE%2CFIXED_ASSET%2CCIP%2CUSERIGHT_ASSET%2CINTANGIBLE_ASSET%2CDEVELOP_EXPENSE%2CGOODWILL%2CLONG_PREPAID_EXPENSE%2CDEFER_TAX_ASSET%2CINVEST_INCOME%2CEXCHANGE_INCOME%2CFAIRVALUE_CHANGE_INCOME%2CASSET_DISPOSAL_INCOME%2COPERATE_COST%2CSURRENDER_VALUE%2CNET_COMPENSATE_EXPENSE%2CNET_CONTRACT_RESERVE%2CPOLICY_BONUS_EXPENSE%2COPERATE_TAX_ADD%2CINCOME_TAX%2CASSET_IMPAIRMENT_INCOME%2CCREDIT_IMPAIRMENT_INCOME%2CNONBUSINESS_EXPENSE%2CFINANCE_EXPENSE%2CSALE_EXPENSE%2CMANAGE_EXPENSE%2CRESEARCH_EXPENSE%2CINTEREST_NI%2CFEE_COMMISSION_NI%2CEARNED_PREMIUM%2CBUSINESS_MANAGE_EXPENSE%2COTHER_CREDITOR_INVEST%2COTHER_EQUITY_INVEST%2CLONG_RECE%2CAVAILABLE_SALE_FINASSET%2CHOLD_MATURITY_INVEST%2CFEE_COMMISSION_EXPENSE&quoteColumns=&filter=(SECUCODE%3D%22000001.SZ%22)&pageNumber=1&pageSize=9&sortTypes=-1&sortColumns=REPORT_DATE&source=HSF10&client=PC&v=09586109542970322"
        );

        let response = REQWEST_CLIENT.get(request_url)
            .header(reqwest::header::ACCEPT, "*/*")
            .header(reqwest::header::ACCEPT_ENCODING, "gzip, deflate, br")
            .header(reqwest::header::ACCEPT_LANGUAGE, "zh-CN,zh;q=0.9,en;q=0.8")
            .header(reqwest::header::CACHE_CONTROL, "no-cache")
            .header(reqwest::header::CONNECTION, "keep-alive")
            // .header(reqwest::header::COOKIE, "qgqp_b_id=d6299473145338f68687834ba37fa719; st_si=77687174285423; AUTH_FUND.EASTMONEY.COM_GSJZ=AUTH*TTJJ*TOKEN; EMFUND0=01-16%2016%3A57%3A06@%23%24%u4E2D%u822A%u65B0%u8D77%u822A%u7075%u6D3B%u914D%u7F6E%u6DF7%u5408A@%23%24005537; EMFUND1=01-16%2017%3A04%3A53@%23%24%u91D1%u4FE1%u6D88%u8D39%u5347%u7EA7%u80A1%u7968A@%23%24006692; EMFUND2=01-16%2020%3A01%3A56@%23%24%u5357%u65B9%u4E0A%u8BC1380ETF@%23%24510290; EMFUND3=01-29%2015%3A02%3A07@%23%24%u534E%u590F%u4E2D%u8BC1%u5168%u6307%u623F%u5730%u4EA7ETF@%23%24515060; EMFUND4=01-30%2014%3A41%3A22@%23%24%u534E%u6CF0%u67CF%u745E%u6D88%u8D39%u6210%u957F%u6DF7%u5408@%23%24001069; EMFUND5=01-30%2014%3A45%3A59@%23%24%u5E7F%u53D1%u6052%u751F%u6D88%u8D39%28QDII-ETF%29@%23%24159699; EMFUND6=01-30%2014%3A47%3A24@%23%24%u5357%u65B9%u7EA2%u5229%u4F4E%u6CE250ETF@%23%24515450; EMFUND7=01-31%2015%3A21%3A23@%23%24%u56FD%u8054%u4E2D%u8BC1%u7164%u70AD%u6307%u6570%28LOF%29A@%23%24168204; EMFUND8=02-02%2008%3A34%3A56@%23%24%u666F%u987A%u957F%u57CE%u652F%u67F1%u4EA7%u4E1A%u6DF7%u5408@%23%24260117; EMFUND9=02-02 10:30:22@#$%u897F%u90E8%u5229%u5F97%u805A%u79BE%u6DF7%u5408A@%23%24007423; st_asi=delete; HAList=ty-1-513130-%u6052%u751F%u79D1%u6280ETF%2Cty-0-300078-%u601D%u521B%u533B%u60E0%2Cty-0-300486-%u4E1C%u6770%u667A%u80FD%2Cty-1-513360-%u6559%u80B2ETF%2Cty-0-300478-%u676D%u5DDE%u9AD8%u65B0%2Cty-0-301589-N%u8BFA%u74E6%2Cty-1-603135-%u4E2D%u91CD%u79D1%u6280%2Cty-0-000001-%u5E73%u5B89%u94F6%u884C%2Cty-0-002400-%u7701%u5E7F%u96C6%u56E2%2Cty-1-601127-%u8D5B%u529B%u65AF; st_pvi=47260449691882; st_sp=2024-01-12%2017%3A28%3A27; st_inirUrl=https%3A%2F%2Fwww.google.com.hk%2F; st_sn=438; st_psi=20240226102321941-113200301321-9024721593")
            .header(reqwest::header::HOST, "datacenter.eastmoney.com")
            .header(reqwest::header::ORIGIN, "https://emweb.securities.eastmoney.com")
            .header(reqwest::header::PRAGMA, "no-cache")
            .header(reqwest::header::REFERER, "https://emweb.securities.eastmoney.com/")
            .header(
                reqwest::header::USER_AGENT,
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
            )
            .header(
                "Sec-Ch-Ua",
                "\"Not A(Brand\";v=\"99\", \"Google Chrome\";v=\"121\", \"Chromium\";v=\"121\""
            )
            .header("Sec-Ch-Ua-Mobile", "?0")
            .header("Sec-Ch-Ua-Platform", "\"macOS\"")
            .header("Sec-Fetch-Dest", "empty")
            .header("Sec-Fetch-Mode", "cors")
            .header("Sec-Fetch-Site", "same-origin")
            .send().await?;

        let body = response.text().await?;

        // println!("*** body={}\n\nhangqin\n\n", body);

        let fund: RptF10FinanceDupont = serde_json::from_str(&body)?;

        // println!("{:?}", fund);

        Ok(fund)
    }

    ///
    /// 杜邦分析 RPT_F10_FINANCE_DUPONT 按年度
    /// Referer: https://emweb.securities.eastmoney.com/pc_hsf10/pages/index.html?type=web&code=SZ000001&color=b#/cwfx/dbfx
    ///
    /// data: https://datacenter.eastmoney.com/securities/api/data/v1/get?reportName=RPT_F10_FINANCE_DUPONT&columns=SECUCODE%2CSECURITY_CODE%2CSECURITY_NAME_ABBR%2CORG_CODE%2CORG_TYPE%2CREPORT_DATE%2CREPORT_TYPE%2CREPORT_DATE_NAME%2CSECURITY_TYPE_CODE%2CNOTICE_DATE%2CUPDATE_DATE%2CCURRENCY%2CNETPROFIT%2CTOTAL_OPERATE_INCOME%2CTOTAL_ASSETS%2CTOTAL_LIABILITIES%2CTOTAL_CURRENT_ASSETS%2CTOTAL_NONCURRENT_ASSETS%2CPARENT_NETPROFIT%2CSALE_NPR%2CTOTAL_ASSETS_TR%2CJROA%2CPARENT_NETPROFIT_RATIO%2CEQUITY_MULTIPLIER%2CROE%2CDEBT_ASSET_RATIO%2CTOTAL_INCOME%2CTOTAL_COST%2CTOTAL_EXPENSE%2CMONETARYFUNDS%2CTRADE_FINASSET%2CNOTE_RECE%2CACCOUNTS_RECE%2CFINANCE_RECE%2COTHER_RECE%2CINVENTORY%2CCREDITOR_INVEST%2CLONG_EQUITY_INVEST%2CINVEST_REALESTATE%2CFIXED_ASSET%2CCIP%2CUSERIGHT_ASSET%2CINTANGIBLE_ASSET%2CDEVELOP_EXPENSE%2CGOODWILL%2CLONG_PREPAID_EXPENSE%2CDEFER_TAX_ASSET%2CINVEST_INCOME%2CEXCHANGE_INCOME%2CFAIRVALUE_CHANGE_INCOME%2CASSET_DISPOSAL_INCOME%2COPERATE_COST%2CSURRENDER_VALUE%2CNET_COMPENSATE_EXPENSE%2CNET_CONTRACT_RESERVE%2CPOLICY_BONUS_EXPENSE%2COPERATE_TAX_ADD%2CINCOME_TAX%2CASSET_IMPAIRMENT_INCOME%2CCREDIT_IMPAIRMENT_INCOME%2CNONBUSINESS_EXPENSE%2CFINANCE_EXPENSE%2CSALE_EXPENSE%2CMANAGE_EXPENSE%2CRESEARCH_EXPENSE%2CINTEREST_NI%2CFEE_COMMISSION_NI%2CEARNED_PREMIUM%2CBUSINESS_MANAGE_EXPENSE%2COTHER_CREDITOR_INVEST%2COTHER_EQUITY_INVEST%2CLONG_RECE%2CAVAILABLE_SALE_FINASSET%2CHOLD_MATURITY_INVEST%2CFEE_COMMISSION_EXPENSE&quoteColumns=&filter=(SECUCODE%3D%22000001.SZ%22)(REPORT_DATE_NAME%3D%22%E5%B9%B4%E6%8A%A5%22)&pageNumber=1&pageSize=9&sortTypes=-1&sortColumns=REPORT_DATE&source=HSF10&client=PC&v=018521110192416668

    pub async fn rpt_f10_finance_dupont_year(_code: &str) -> Result<RptF10FinanceDupont> {
        // Query String Parameters:
        //
        // reportName: RPT_F10_FINANCE_DUPONT
        // columns: SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,ORG_CODE,ORG_TYPE,REPORT_DATE,REPORT_TYPE,REPORT_DATE_NAME,SECURITY_TYPE_CODE,NOTICE_DATE,UPDATE_DATE,CURRENCY,NETPROFIT,TOTAL_OPERATE_INCOME,TOTAL_ASSETS,TOTAL_LIABILITIES,TOTAL_CURRENT_ASSETS,TOTAL_NONCURRENT_ASSETS,PARENT_NETPROFIT,SALE_NPR,TOTAL_ASSETS_TR,JROA,PARENT_NETPROFIT_RATIO,EQUITY_MULTIPLIER,ROE,DEBT_ASSET_RATIO,TOTAL_INCOME,TOTAL_COST,TOTAL_EXPENSE,MONETARYFUNDS,TRADE_FINASSET,NOTE_RECE,ACCOUNTS_RECE,FINANCE_RECE,OTHER_RECE,INVENTORY,CREDITOR_INVEST,LONG_EQUITY_INVEST,INVEST_REALESTATE,FIXED_ASSET,CIP,USERIGHT_ASSET,INTANGIBLE_ASSET,DEVELOP_EXPENSE,GOODWILL,LONG_PREPAID_EXPENSE,DEFER_TAX_ASSET,INVEST_INCOME,EXCHANGE_INCOME,FAIRVALUE_CHANGE_INCOME,ASSET_DISPOSAL_INCOME,OPERATE_COST,SURRENDER_VALUE,NET_COMPENSATE_EXPENSE,NET_CONTRACT_RESERVE,POLICY_BONUS_EXPENSE,OPERATE_TAX_ADD,INCOME_TAX,ASSET_IMPAIRMENT_INCOME,CREDIT_IMPAIRMENT_INCOME,NONBUSINESS_EXPENSE,FINANCE_EXPENSE,SALE_EXPENSE,MANAGE_EXPENSE,RESEARCH_EXPENSE,INTEREST_NI,FEE_COMMISSION_NI,EARNED_PREMIUM,BUSINESS_MANAGE_EXPENSE,OTHER_CREDITOR_INVEST,OTHER_EQUITY_INVEST,LONG_RECE,AVAILABLE_SALE_FINASSET,HOLD_MATURITY_INVEST,FEE_COMMISSION_EXPENSE
        // quoteColumns:
        // filter: (SECUCODE="000001.SZ")(REPORT_DATE_NAME="年报")
        // pageNumber: 1
        // pageSize: 9
        // sortTypes: -1
        // sortColumns: REPORT_DATE
        // source: HSF10
        // client: PC
        // v: 018521110192416668

        let request_url = format!(
            "https://datacenter.eastmoney.com/securities/api/data/v1/get?reportName=RPT_F10_FINANCE_DUPONT&columns=SECUCODE%2CSECURITY_CODE%2CSECURITY_NAME_ABBR%2CORG_CODE%2CORG_TYPE%2CREPORT_DATE%2CREPORT_TYPE%2CREPORT_DATE_NAME%2CSECURITY_TYPE_CODE%2CNOTICE_DATE%2CUPDATE_DATE%2CCURRENCY%2CNETPROFIT%2CTOTAL_OPERATE_INCOME%2CTOTAL_ASSETS%2CTOTAL_LIABILITIES%2CTOTAL_CURRENT_ASSETS%2CTOTAL_NONCURRENT_ASSETS%2CPARENT_NETPROFIT%2CSALE_NPR%2CTOTAL_ASSETS_TR%2CJROA%2CPARENT_NETPROFIT_RATIO%2CEQUITY_MULTIPLIER%2CROE%2CDEBT_ASSET_RATIO%2CTOTAL_INCOME%2CTOTAL_COST%2CTOTAL_EXPENSE%2CMONETARYFUNDS%2CTRADE_FINASSET%2CNOTE_RECE%2CACCOUNTS_RECE%2CFINANCE_RECE%2COTHER_RECE%2CINVENTORY%2CCREDITOR_INVEST%2CLONG_EQUITY_INVEST%2CINVEST_REALESTATE%2CFIXED_ASSET%2CCIP%2CUSERIGHT_ASSET%2CINTANGIBLE_ASSET%2CDEVELOP_EXPENSE%2CGOODWILL%2CLONG_PREPAID_EXPENSE%2CDEFER_TAX_ASSET%2CINVEST_INCOME%2CEXCHANGE_INCOME%2CFAIRVALUE_CHANGE_INCOME%2CASSET_DISPOSAL_INCOME%2COPERATE_COST%2CSURRENDER_VALUE%2CNET_COMPENSATE_EXPENSE%2CNET_CONTRACT_RESERVE%2CPOLICY_BONUS_EXPENSE%2COPERATE_TAX_ADD%2CINCOME_TAX%2CASSET_IMPAIRMENT_INCOME%2CCREDIT_IMPAIRMENT_INCOME%2CNONBUSINESS_EXPENSE%2CFINANCE_EXPENSE%2CSALE_EXPENSE%2CMANAGE_EXPENSE%2CRESEARCH_EXPENSE%2CINTEREST_NI%2CFEE_COMMISSION_NI%2CEARNED_PREMIUM%2CBUSINESS_MANAGE_EXPENSE%2COTHER_CREDITOR_INVEST%2COTHER_EQUITY_INVEST%2CLONG_RECE%2CAVAILABLE_SALE_FINASSET%2CHOLD_MATURITY_INVEST%2CFEE_COMMISSION_EXPENSE&quoteColumns=&filter=(SECUCODE%3D%22000001.SZ%22)(REPORT_DATE_NAME%3D%22%E5%B9%B4%E6%8A%A5%22)&pageNumber=1&pageSize=9&sortTypes=-1&sortColumns=REPORT_DATE&source=HSF10&client=PC&v=018521110192416668"
        );

        let response = REQWEST_CLIENT.get(request_url)
            .header(reqwest::header::ACCEPT, "*/*")
            .header(reqwest::header::ACCEPT_ENCODING, "gzip, deflate, br")
            .header(reqwest::header::ACCEPT_LANGUAGE, "zh-CN,zh;q=0.9,en;q=0.8")
            .header(reqwest::header::CACHE_CONTROL, "no-cache")
            .header(reqwest::header::CONNECTION, "keep-alive")
            // .header(reqwest::header::COOKIE, "qgqp_b_id=d6299473145338f68687834ba37fa719; st_si=77687174285423; AUTH_FUND.EASTMONEY.COM_GSJZ=AUTH*TTJJ*TOKEN; EMFUND0=01-16%2016%3A57%3A06@%23%24%u4E2D%u822A%u65B0%u8D77%u822A%u7075%u6D3B%u914D%u7F6E%u6DF7%u5408A@%23%24005537; EMFUND1=01-16%2017%3A04%3A53@%23%24%u91D1%u4FE1%u6D88%u8D39%u5347%u7EA7%u80A1%u7968A@%23%24006692; EMFUND2=01-16%2020%3A01%3A56@%23%24%u5357%u65B9%u4E0A%u8BC1380ETF@%23%24510290; EMFUND3=01-29%2015%3A02%3A07@%23%24%u534E%u590F%u4E2D%u8BC1%u5168%u6307%u623F%u5730%u4EA7ETF@%23%24515060; EMFUND4=01-30%2014%3A41%3A22@%23%24%u534E%u6CF0%u67CF%u745E%u6D88%u8D39%u6210%u957F%u6DF7%u5408@%23%24001069; EMFUND5=01-30%2014%3A45%3A59@%23%24%u5E7F%u53D1%u6052%u751F%u6D88%u8D39%28QDII-ETF%29@%23%24159699; EMFUND6=01-30%2014%3A47%3A24@%23%24%u5357%u65B9%u7EA2%u5229%u4F4E%u6CE250ETF@%23%24515450; EMFUND7=01-31%2015%3A21%3A23@%23%24%u56FD%u8054%u4E2D%u8BC1%u7164%u70AD%u6307%u6570%28LOF%29A@%23%24168204; EMFUND8=02-02%2008%3A34%3A56@%23%24%u666F%u987A%u957F%u57CE%u652F%u67F1%u4EA7%u4E1A%u6DF7%u5408@%23%24260117; EMFUND9=02-02 10:30:22@#$%u897F%u90E8%u5229%u5F97%u805A%u79BE%u6DF7%u5408A@%23%24007423; st_asi=delete; HAList=ty-1-513130-%u6052%u751F%u79D1%u6280ETF%2Cty-0-300078-%u601D%u521B%u533B%u60E0%2Cty-0-300486-%u4E1C%u6770%u667A%u80FD%2Cty-1-513360-%u6559%u80B2ETF%2Cty-0-300478-%u676D%u5DDE%u9AD8%u65B0%2Cty-0-301589-N%u8BFA%u74E6%2Cty-1-603135-%u4E2D%u91CD%u79D1%u6280%2Cty-0-000001-%u5E73%u5B89%u94F6%u884C%2Cty-0-002400-%u7701%u5E7F%u96C6%u56E2%2Cty-1-601127-%u8D5B%u529B%u65AF; st_pvi=47260449691882; st_sp=2024-01-12%2017%3A28%3A27; st_inirUrl=https%3A%2F%2Fwww.google.com.hk%2F; st_sn=438; st_psi=20240226102321941-113200301321-9024721593")
            .header(reqwest::header::HOST, "datacenter.eastmoney.com")
            .header(reqwest::header::ORIGIN, "https://emweb.securities.eastmoney.com")
            .header(reqwest::header::PRAGMA, "no-cache")
            .header(reqwest::header::REFERER, "https://emweb.securities.eastmoney.com/")
            .header(
                reqwest::header::USER_AGENT,
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
            )
            .header(
                "Sec-Ch-Ua",
                "\"Not A(Brand\";v=\"99\", \"Google Chrome\";v=\"121\", \"Chromium\";v=\"121\""
            )
            .header("Sec-Ch-Ua-Mobile", "?0")
            .header("Sec-Ch-Ua-Platform", "\"macOS\"")
            .header("Sec-Fetch-Dest", "empty")
            .header("Sec-Fetch-Mode", "cors")
            .header("Sec-Fetch-Site", "same-origin")
            .send().await?;

        let body = response.text().await?;

        // println!("*** body={}\n\nhangqin\n\n", body);

        let fund: RptF10FinanceDupont = serde_json::from_str(&body)?;

        // println!("{:?}", fund);

        Ok(fund)
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[tokio::test]
    async fn test_stock_rpt_f10_finance_dupont() {
        let result = RptF10FinanceDupont::rpt_f10_finance_dupont("000001.SZ").await;

        assert_eq!(result.is_ok(), true);
        if let Ok(dupont) = result {
            assert_eq!(dupont.message.as_str(), Some("ok"));
            println!("dupont.result.data.first={:?}\n", dupont.result.data.first());
        }
    }

    #[tokio::test]
    async fn test_stock_rpt_f10_finance_dupont_year() {
        let result = RptF10FinanceDupont::rpt_f10_finance_dupont_year("000001.SZ").await;

        assert_eq!(result.is_ok(), true);
        if let Ok(dupont) = result {
            assert_eq!(dupont.message.as_str(), Some("ok"));
            println!("dupont.result.data.first={:?}\n", dupont.result.data.first());
        }
    }
}
